﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Model;
using BLL;
namespace ClassSystem
{
    public partial class ASPLogin : System.Web.UI.Page
    {
        DBHelperF db = new DBHelperF();
        protected void Page_Load(object sender, EventArgs e)
        {
            this.Label1.Text = DateTime.Now.ToLongDateString().ToString();
        }

        protected void username_TextChanged(object sender, EventArgs e)
        {

        }

        protected void Button1_Click(object sender, EventArgs e)
        {
           //Student info = new Student();
           // info.StudentID = this.Username.Text.Trim();
           // info.UserPwd = this.txtPwd.Text.Trim();
           // if (bll.UserLogin(info))
           // {
           //     Session["ID"] = info.UserID;

           //     Response.Write("<script>alert('登录成功')</script>");
           // }
           // else
           // {

           //     Response.Write("<script>alert('登录失败')</script>");
           // }
        }

        protected void Button1_Click1(object sender, EventArgs e)
        {
            string sql = string.Format("select * from [dbo].[StudentInfoS] where StudentID='{0}' and StudentPwd='{1}'",
                this.txtname.Text.Trim(),
                this.txtpwd.Text.Trim());
            if (this.txtname.Text == "" || this.txtpwd.Text == "")
            {
                Response.Write("账号和密码不能为空！");
            }
            else
            {
                if (db.GetData(sql).Tables[0].Rows.Count > 0)
                {
                    Response.Redirect("ASPIndexStudent.aspx");
                }
                else
                {
                    Response.Write("<script>alert('登录失败!')</script>");
                }
            }

            //LoginModel lg = new LoginModel();
            //int StudentID = Convert.ToInt32(this.txtname.Text.Trim());
            //string StudentPwd = this.txtpwd.Text.Trim();
            //if (bll.Studentlogin(StudentID, StudentPwd))
            //{
            //    Response.Redirect("ASPIndexStudent.aspx");
            //}
            //else
            //{
            //    Response.Write("<script>alert('登录失败!')</script>");
            //}

            //if (this.DropDownList1.SelectedValue == "2")
            //{
            //    int TeacherID = Convert.ToInt32(this.Username.Text.Trim());
            //    string TeacherPwd = this.password.Text.Trim();
            //    if (bll.Teacherlogin(lg))
            //    {
            //        Response.Redirect("ASPIndexTeacher.aspx");
            //    }
            //    else
            //    {
            //        Response.Write("<script>alert('登录失败!')</script>");
            //    }

            ////if (this.DropDownList1.SelectedValue == "3")
            ////{
            ////    string AdminID = this.Username.Text.Trim();
            ////    string AdminPwd = this.password.Text.Trim();
            ////    if (bll.Adminlogin(lg))
            ////    {
            ////        Response.Redirect("ASPIndexAdmin.aspx");
            ////    }
            ////    else
            ////    {
            ////        Response.Write("<script>alert('登录失败!')</script>");
            ////    }
            ////}


        }

        protected void Button1_Click2(object sender, EventArgs e)
        {
            
        }
    }
}